<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<link rel="stylesheet" href="__STATIC__/css/cart.css" />
		<script src="__STATIC__/js/jquery-1.8.2.min.js">
			
		</script>
        <script>
        	$(function(){
        		$('.minus').click(function(){
        			var num=$(this).siblings('input').val();
        			num=parseInt(num);
        			var sid=$(this).siblings('input').attr('sid');
        			if(num>1){
        				num--;
        				$(this).siblings('input').val(num);
        			}
        			var _this=$(this);
        			    $.ajax({
        				type:"post",
        				url:"{|U:'updateCart'}",
        				data:{'sid':sid,'num':num},
        				dataType:'json',
        				success:function(phpData){
       						
        						_this.parents(".speinfo").find(".zongji").html('￥'+phpData['goodtotal']);
        						$('#alltotal').html('￥'+phpData['alltotal']);
        						
        						
        					
        					
        				}
        			})

        		})
        		$('.add').click(function(){
        			var num=$(this).siblings('input').val();
        			var kucun=parseInt($(this).siblings('input').attr('kucun'));
        			var sid=$(this).siblings('input').attr('sid');
        			num=parseInt(num);
        			    if(num<kucun){
        				num++;
        				$(this).siblings('input').val(num);
        			}
//      			    在ajax中不能使用$(this);
        			var _this=$(this);
        			$.ajax({
        				type:"post",
        				url:"{|U:'updateCart'}",
        				data:{'sid':sid,'num':num},
        				dataType:'json',
        				success:function(phpData){

        						_this.parents(".speinfo").find(".zongji").html('￥'+phpData['goodtotal']);
        						$('#alltotal').html('￥'+phpData['alltotal']);
        						
        					
        					
        				}
        			})
        		})
////      		点击x是删除购物车

        		$('.del').click(function(){
        			var sid=$(this).parents('tr').find('input').attr('sid');
        			var _this=$(this);
        			$.ajax({
        				type:"post",
        				url:"{|U:'delCart'}",
        				data:{'sid':sid},

        				success:function(phpData){
//      					将本行隐藏
                            _this.parents('tr').hide();
                            
//                           更改价格总计
                            $('#alltotal').html('￥'+phpData);


        				}
        			})
        		})
        	})
        </script>
	</head>
	<body>
			<div class="top">
				<div class="topbar">
				
					<div class="left">
						<ul>
							<li class="logo">
		                     
						       <a href=""></a>
							</li>
							<li class="twofont"><a href="">商城</a></li>
							<li class="twofont"><a href="">手机</a></li>
							<li class="twofont"><a href="">配件</a></li>
							<li class="threefont"><a href="">体验店</a></li>
						</ul>
					
						
					</div>
					<div class="right">
						<ul>
							 <li class="login">
							    <span></span>
							 	<a href="">注册</a>
							 	<a href="">登录</a>
							 </li>
					       
					         <li class="cart">
					   	        <a href=""></a>
					         </li>
						</ul>
					  
						
					</div>
				</div>
		</div>
		<div class="cartbj">
				<p>
					<a href="">首页&nbsp&nbsp></a><a href="">&nbsp&nbsp个人中心</a>
				</p>
		</div>
		<div class="cartdiv">
			<form action="" method="post">
		    <h1>
		    	您的购物车包含2个产品
		    </h1>
			<table border="1">
			
					<th class="ft">产品</th>
					<th class="sd">描述</th>
					<th class="td">单价</th>
					<th class="fh">数量</th>
					<th class="wu">小计</th>
					<th class="op">操作</th>
		        <foreach from="$goodsData" key="$k" value="$v">
				<tr class="speinfo">
					<td> 
						<img src="__STATIC__/images/143945163655.png" alt="" />
						
					</td>
					<td>{$v.name}</td>
					<td>￥{$v.price}</td>
					<td>
						<div class="updatenum">
							<a href="javascript:;" class="minus">-</a>
							<input type="text" value="{$v.num}" kucun="{$v.kucun}" sid="{$k}" id="num"/>
							<a href="javascript:;" class="add">+</a>
						</div>
					</td>
					<td class="zongji">
						￥{$v.total}
					</td>
					<td>
						
						<a href="javascript:;" class="del">
							×
						</a>
							
						

					</td>
					
				</tr>
				</foreach>
				<tr class="total">
					<td colspan="2"></td>
					<td colspan="2">商品总计</td>
					<td colspan="2" id="alltotal">￥{$alltotal}</td>
					
				</tr>
			</table>
			</form>
			<div class="buy">
				<div class="outgw">
					<a href="" class="jxgw">继续购物</a>
					<a href="{|U:'Myorder/index'}" class="ljjs">立即结算</a>
					
				</div>

			</div>
		</div>
		<div class="rmsp">
			热门商品
		</div>
		<div class="rmpro">
			<div class="jtsp">
				<img src="__STATIC__/images/142728760152.jpg" alt="" />
				<div class="des">
					<div class="spname">
						Z9 mini皮质保护套
					</div>
					<div class="pri">
						￥169.00
					</div>
					
				</div>
			</div>
			<div class="jtsp">
								<img src="__STATIC__/images/142728760152.jpg" alt="" />
				<div class="des">
					<div class="spname">
						Z9 mini皮质保护套
					</div>
					<div class="pri">
						￥169.00
					</div>
					
				</div>
			</div>
			<div class="jtsp">
								<img src="__STATIC__/images/142728760152.jpg" alt="" />
				<div class="des">
					<div class="spname">
						Z9 mini皮质保护套
					</div>
					<div class="pri">
						￥169.00
					</div>
					
				</div>
			</div>
			<div class="jtsp">
								<img src="__STATIC__/images/142728760152.jpg" alt="" />
				<div class="des">
					<div class="spname">
						Z9 mini皮质保护套
					</div>
					<div class="pri">
						￥169.00
					</div>
					
				</div>
			</div>
		</div>
					<div class="aboutus">
					<div class="alink">
						<a href="">关于我们</a>
						<a href="">联系我们</a>
						<a href="">新闻中心</a>
						<a href="">加入我们</a>
						<a href="">公益</a>
						<a href="">星空之约</a>
					</div>
					<p>
						2012-2015 努比亚 版权所有 粤ICP备10006213号-2 ICP经营许可证编号：粤B2-20120688深圳市市场监督管理局企业主体身份公示 努比亚技术有限公司
					</p>
					
					<div class="asright">
						<a href="" class="weather">
						</a>
						<a href="" class="phone">

						</a>
						<a href="" class="ewm">
						</a>
						<a href=""  class="service">
						</a>
						<span>
							
						</span>
					</div>
			</div>
	</body>
</html>
